﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WyUnity.Utility.ExtentionMethods
{
	public static class IComparableExtensions
	{
		#region Functions

		#region Between

		/// <summary>
		/// 检查当前的值是否居于两者之间(包括等于）
		/// </summary>
		public static bool Between<T>(this T value, T min, T max, IComparer<T> comparer = null) where T : IComparable
		{
			comparer = comparer.NullCheck(new GenericComparer<T>());
			return comparer.Compare(max, value) >= 0 && comparer.Compare(value, min) >= 0;
		}

		#endregion

		#endregion
	}
}
